<template>
  <div id="contsainer"></div>
</template>
<script>
export default {
  data() {
    return {
      viewer: null
    }
  },
  mounted() {
    this.initCesium()
    this.addPolylineArrowMaterial(this.viewer)
  },
  methods: {
    initCesium() {
      this.viewer = new Cesium.Viewer('contsainer', {
        animation: false,
        baseLayerPicker: false,
        fullscreenButton: false,
        geocoder: false,
        homeButton: false,
        infoBox: false,
        sceneModePicker: false,
        navigationHelpButton: false,
        scene3DOnly: true,
        timeline: false,
        selectionIndicator: false, //是否显示选取指示器组件
        shouldAnimate: false, //自动播放动画控件
        shadows: true, //是否显示光照投射的阴影
        terrainShadows: Cesium.ShadowMode.RECEIVE_ONLY, //地质接收阴影
        sceneMode: Cesium.SceneMode.SCENE3D
      })
      this.viewer._cesiumWidget._creditContainer.style.display = 'none' //	去除版权信息
    },
    addPolylineArrowMaterial(viewer) {
      viewer.entities.add({
        name: 'Red line on terrain',
        polyline: {
          positions: Cesium.Cartesian3.fromDegreesArray([45, 50, 55, 50, 55, 60, 45, 60, 45, 55]),
          width: 20,
          material: new Cesium.PolylineArrowMaterialProperty(Cesium.Color.PINK),
          depthFailMaterial: Cesium.Color('#666'), //位于地下的材质,不给地下的材质，位于地下的线就不可见
          clampToGround: false, //折线固定在地面
          arcType: Cesium.ArcType.GEODESIC //定义连接点采用的路径
        }
      })
      viewer.zoomTo(viewer.entities)
    }
  }
}
</script>
<style scoped>
#contsainer {
  height: 100%;
  width: 100%;
  background-color: red;
}
</style>
